'''
This script check in the parameters of a ppf file and an eqt file into the database
Usage:
    checkin.py dbname tablename ppffile.ppf
For Example:
    checkin.py mydatabase.dffdb AMBER1 test.ppf
    It check the parameters in test.ppf and test.eqt into the table AMBER1 in mydatabase.dffdb
Created on 2009-8-26

@author: madlee
'''

import kuai

if __name__ == '__main__':
    from sys import argv
    if len(argv) != 4:
        print __doc__
    else:
        from kuai.dff.dffdb import Database
        ff, eqt = kuai.read_ff(argv[3])
        db = Database(argv[1], argv[2])
        version, newdata = db.checkin(ff, eqt)
        print "%d new item(s) were added into the %s in %s, the latest version is %d" % (len(newdata), argv[2], argv[1], version)
